<template>
  <div>
    <main>
      <div
        class="business"
        v-for="(item, index) in goodlist[0].products"
        :key="item.id"
      >
        <div class="shop">
          <div
            data-v-2a6ae55b=""
            role="checkbox"
            tabindex="0"
            aria-checked="undefined"
            class="van-checkbox checkin"
            style="margin-right: 0.08rem"
          >
            <div
              class="van-checkbox__icon van-checkbox__icon--round"
              style="font-size: 18px"
            >
              <i
                :class="[
                  'van-icon van-icon-success checkof',
                  item.isStorecheck ? 'checked' : '',
                ]"
                @click="handleStoreCheck(index)"
                >&#xe6c2;</i
              >
            </div>
          </div>
          <!-- <div class="checkin">
            <i
              :class="['iconfont checkof', item.isStorecheck ? 'checked' : '']"
              @click="handleStoreCheck(index)"
              >&#xe6c2;</i
            >
          </div> -->
          <i class="iconfont home">&#xe75c;</i>
          <a data-v-2a6ae55b="">{{ item.storeName }} ></a>
        </div>
        <div class="shop-list">
          <div class="van-checkbox">
            <span class="label">
              <div class="content">
                <div
                  data-v-2a6ae55b=""
                  role="checkbox"
                  tabindex="0"
                  aria-checked="undefined"
                  class="van-checkbox checkin"
                  style="margin-right: 0.08rem"
                >
                  <div
                    class="van-checkbox__icon van-checkbox__icon--round"
                    style="font-size: 18px"
                  >
                    <i
                      @click="handleCheck(index)"
                      :class="[
                        'van-icon van-icon-success checkof',
                        item.ischeck ? 'checked' : '',
                      ]"
                      >&#xe6c2;</i
                    >
                  </div>
                </div>
                <!-- <i
                  :class="['iconfont checkof', { checked: item.ischeck }]"
                  @click="handleCheck(index, index)"
                  >&#xe6c2;</i
                > -->
                <div class="content-left">
                  <img :src="imgs + item.iconImg" alt="" />
                </div>
                <div class="content-right">
                  <div data-v-2a6ae55b="" class="title">
                    {{ item.name }}
                  </div>
                  <div data-v-2a6ae55b="" class="kg">
                    <span data-v-2a6ae55b="">{{ item.skuAttr }}</span>
                  </div>
                  <div data-v-2a6ae55b="" class="pro">
                    ¥<span data-v-2a6ae55b="">{{
                      parseInt(item.nowPrice * item.num)
                    }}</span>
                  </div>
                  <div class="nums">
                    <button
                      type="button"
                      :class="[
                        'van-stepper__minus van-stepper__minus--disabled de',
                        item.productCount == 1 ? 'disabled' : '',
                      ]"
                      style="width: 15px; height: 15px"
                      @click="handleAddCount(index, true)"
                    ></button>
                    <!-- <button
                      type="button"
                      :class="['de', item.productCount == 1 ? 'disabled' : '']"
                      @click="handleAddCount(index, index, true)">-</button> -->
                    <input type="text" class="input" :value="item.num" />
                    <button
                      type="button"
                      class="van-stepper__plus add"
                      style="width: 15px; height: 15px"
                      @click="handleAddCount(index)"
                    ></button>
                    <!-- <button
                      type="button"
                      class="add"
                      @click="handleAddCount(index, index)"
                    >
                      +
                    </button> -->
                  </div>
                </div>
              </div>
            </span>
          </div>
        </div>
      </div>
      <div
        v-if="isVisible"
        data-v-2a6ae55b=""
        class="bottom-bar"
        style="bottom: 50px"
      >
        <div
          data-v-2a6ae55b=""
          role="checkbox"
          tabindex="0"
          aria-checked="false"
          class="van-checkbox"
        >
          <div class="van-checkbox__icon van-checkbox__icon--round">
            <i
              :class="[
                'van-icon van-icon-success',
                { 'checkbox-on': allInfo.allCheck },
              ]"
              @click="handleAllCheck"
              ><!----></i
            >
          </div>
          <span class="van-checkbox__label">全选</span>
        </div>
        <div data-v-2a6ae55b="" class="bar" @click="handleDel()">删除</div>
      </div>
      <div
        v-else
        data-v-2a6ae55b=""
        class="van-submit-bar"
        style="bottom: 50px"
      >
        <div data-v-2a6ae55b="" class="van-submit-bar__bar">
          <div
            data-v-2a6ae55b=""
            role="checkbox"
            tabindex="0"
            aria-checked="false"
            class="van-checkbox"
          >
            <div class="van-checkbox__icon van-checkbox__icon--round">
              <i
                :class="[
                  'van-icon van-icon-success',
                  { 'checkbox-on': allInfo.allCheck },
                ]"
                @click="handleAllCheck"
                ><!----></i
              >
            </div>
            <span class="van-checkbox__label">全选</span>
          </div>
          <div data-v-2a6ae55b="" class="van-submit-bar__text">
            <span data-v-2a6ae55b="">合计：</span
            ><span data-v-2a6ae55b="" class="van-submit-bar__price"
              >¥<span
                data-v-2a6ae55b=""
                class="van-submit-bar__price van-submit-bar__price--integer"
                >{{ parseInt(allInfo.checkPrice) }}</span
              >.00</span
            >
          </div>
          <button
            data-v-2a6ae55b=""
            @submit.prevent="onSubmit"
            :class="[
              'van-button  van-button--normal van-button--disabled van-button--round  van-submit-bar__button',
               allInfo.checkNum <= 0?'':'van-button--danger',
            ]"
          >
            <div data-v-2a6ae55b="" class="van-button__content">
              <router-link data-v-2a6ae55b="" to="/pay">提交订单</router-link>
            </div>
          </button>
        </div>
      </div>
      <!-- <div class="submit">
        <div class="van-checkbox">

          <i
            :class="['iconfont', { 'checkbox-on': allInfo.allCheck }]"
            @click="handleAllCheck"
            >&#xe6c2;</i
          >
          <span class="label">全选</span>
        </div>
        <div class="text">
          <span>合计：</span>
          <span class="price"
            >¥<span class="integer">{{ allInfo.checkPrice }}</span
            >.00</span
          >
        </div>
        <router-link class="button" to="/pay">提交订单</router-link>
      </div> -->
    </main>
  </div>
</template>

<script>
export default {
  props: {
    isVisible: Boolean,
  },
  computed: {
    goodlist() {
      console.log(this.$store.state.good.goodlist)
      return this.$store.state.good.goodlist;
    },
    allInfo() {
      return this.$store.getters["good/allInfo"];
    },
  },
  data() {
    return {
      cartList: [],
      imgs: "https://caiba-produce.oss-cn-beijing.aliyuncs.com//",
      c: 0,
      checked: true,
      isOk: true,
    };
  },
  methods: {
    onSubmit: function () {
      if (this.allInfo.checkNum <= 0) {
        return false;
      }
      else{
        return true;
      }
    },
    handleAddCount(index, bool) {
      this.$store.commit("good/goodNumMut", { index, bool });
    },
    handleCheck(index) {
      this.$store.commit("good/goodCheckMut", index);
    },
    handleStoreCheck(index) {
      this.$store.commit("good/goodStoreMut", index);
    },
    handleAllCheck() {
      this.$store.commit("good/goodAllCheckMut", this.allInfo.allCheck);
    },
    handleDel() {
      //删除选中商品
      this.$store.commit("good/goodDelCheckMut");
    },
  },
  created() {
    // for(let i=0;i<this.goodlist[0].products.lengtn;i++){
    //   if(this.goodlist[0].products[i].storeId==)
    // };
  },
};
</script>

<style lang="less" scoped>
@import url(../../assets/css/mainCart.less);
.content {
  margin-top: 0px !important;
  background: #fff !important;
}
.van-button-painter{
  pointer-events:auto
}

</style>